
clLabel::clLabel(clOutPutDevice *lOutPutDevice): clMain(){
	Device			= lOutPutDevice;
	Lenght			= 0;
	LeftCorner.X	= -1;
	LeftCorner.Y	= -1;
	Aligment		= AligmentLeft;
};

void clLabel::SetXYPosition(int X, int Y){
	Device->SetXYPosition(X, Y);
}

void clLabel::SetString(char *String){
	uint16_t StringLenght = strlen(String);
	uint8_t CharMerge = '\0';
	char SpaceChar[] = " ";

	if ((LeftCorner.X != -1) && (LeftCorner.Y != -1)){
		Device->SetXYPosition(LeftCorner.X, LeftCorner.Y);
	}

	if ((Aligment == AligmentRight) && (StringLenght < Lenght))
	{
		uint8_t SpaceCount	= Lenght - StringLenght;
		while (SpaceCount--)
		{
			Device->Print(SpaceChar);
		}
	}
	
	if ((Lenght != 0) && (StringLenght > Lenght)){
		CharMerge		= String[Lenght];
		String[Lenght]	= '\0';
	}
	
	Device->Print(String);
	
	if (CharMerge != '\0'){
		String[Lenght]	= CharMerge;
	}
}
